using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using EventFlowLibrary.Player;

namespace ScreenManagement
{
    /// <summary>
    /// The options screen is brought up over the top of the main menu
    /// screen, and gives the user a chance to configure the game
    /// in various hopefully useful ways.
    /// </summary>
    class CreditsScreen : MenuScreen
    {
        #region Fields
        ContentManager content;
        SpriteFont spriteFont;

        Texture2D gradient, logos;

        double timeSinceIncrement = 0.0f;
        bool exiting = false;// this is to hide images as the screen is fading on "ExitScreen"
        #endregion

        #region Initialization


        /// <summary>
        /// Constructor.
        /// </summary>
        public CreditsScreen()
            : base("Credits")
        {

            //MenuEntry back = new MenuEntry("Back");

            //back.Selected += OnCancel;
            
            //MenuEntries.Add(back);
        }

        public override void LoadContent()
        {
            if (content == null)
                content = new ContentManager(ScreenManager.Game.Services, "Content");

            spriteFont = content.Load<SpriteFont>("Fonts/gameFontSmall");

            gradient = content.Load<Texture2D>("Textures/Screens/Gradient");
            logos = content.Load<Texture2D>("Textures/Screens/trimmed");
        }

        public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            if (timeSinceIncrement <= 0.03f)
                timeSinceIncrement += gameTime.ElapsedGameTime.TotalSeconds;

            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
        }

        public override void Draw(GameTime gameTime)
        {
            if (!exiting)
            {
                int width = this.ScreenManager.GraphicsDevice.Viewport.Width;

                this.ScreenManager.SpriteBatch.Begin();

                this.ScreenManager.SpriteBatch.Draw(gradient, new Rectangle(0, 0, 1280, 720), new Color(0.7f, 0.7f, 0.7f, 0.7f));
                this.ScreenManager.SpriteBatch.Draw(logos, new Rectangle(0, 0, 1280, 720), Color.White);

                this.ScreenManager.SpriteBatch.DrawString(spriteFont, "Development/Modeling/Animation/Sound Effects: ", new Vector2((width / 2) - (spriteFont.MeasureString("Development/Modeling/Animation/Sound Effects: ").X / 2) + 2, 202), Color.Black);
                this.ScreenManager.SpriteBatch.DrawString(spriteFont, "James Fogarty", new Vector2((width / 2) - (spriteFont.MeasureString("James Fogarty").X / 2) + 2, 202 + spriteFont.LineSpacing), Color.Black);

                this.ScreenManager.SpriteBatch.DrawString(spriteFont, "Character Modeling: ", new Vector2((width / 2) - (spriteFont.MeasureString("Character Modeling: ").X / 2) + 2, 202 + spriteFont.LineSpacing * 3), Color.Black);
                this.ScreenManager.SpriteBatch.DrawString(spriteFont, "Marilyn Anderson", new Vector2((width / 2) - (spriteFont.MeasureString("Marilyn Anderson").X / 2) + 2, 202 + spriteFont.LineSpacing * 4), Color.Black);

                this.ScreenManager.SpriteBatch.DrawString(spriteFont, "Story: ", new Vector2((width / 2) - (spriteFont.MeasureString("Story: ").X / 2) + 2, 202 + spriteFont.LineSpacing * 6), Color.Black);
                this.ScreenManager.SpriteBatch.DrawString(spriteFont, "Julia Fogarty", new Vector2((width / 2) - (spriteFont.MeasureString("Julia Fogarty").X / 2) + 2, 202 + spriteFont.LineSpacing * 7), Color.Black);

                this.ScreenManager.SpriteBatch.DrawString(spriteFont, "Music Composer: ", new Vector2((width / 2) - (spriteFont.MeasureString("Music Composer: ").X / 2) + 2, 202 + spriteFont.LineSpacing * 9), Color.Black);
                this.ScreenManager.SpriteBatch.DrawString(spriteFont, "Zack Parrish/ZackParrish.com", new Vector2((width / 2) - (spriteFont.MeasureString("Zack Parrish/ZackParrish.com").X / 2) + 2, 202 + spriteFont.LineSpacing * 10), Color.Black);
                this.ScreenManager.SpriteBatch.DrawString(spriteFont, "\"Il Valzer Finale\\NothingEverLasts\\Revealing the Truth\"", new Vector2((width / 2) - (spriteFont.MeasureString("\"Il Valzer Finale\\NothingEverLasts\\Revealing the Truth\"").X / 2) + 2, 202 + spriteFont.LineSpacing * 11), Color.Black);

                this.ScreenManager.SpriteBatch.DrawString(spriteFont, "Development/Modeling/Animation/Sound Effects: ", new Vector2((width / 2) - (spriteFont.MeasureString("Development/Modeling/Animation/Sound Effects: ").X / 2), 200), Color.White);
                this.ScreenManager.SpriteBatch.DrawString(spriteFont, "James Fogarty", new Vector2((width / 2) - (spriteFont.MeasureString("James Fogarty").X / 2), 200 + spriteFont.LineSpacing), Color.White);

                this.ScreenManager.SpriteBatch.DrawString(spriteFont, "Character Modeling: ", new Vector2((width / 2) - (spriteFont.MeasureString("Character Modeling: ").X / 2), 200 + spriteFont.LineSpacing * 3), Color.White);
                this.ScreenManager.SpriteBatch.DrawString(spriteFont, "Marilyn Anderson", new Vector2((width / 2) - (spriteFont.MeasureString("Marilyn Anderson").X / 2), 200 + spriteFont.LineSpacing * 4), Color.White);

                this.ScreenManager.SpriteBatch.DrawString(spriteFont, "Story: ", new Vector2((width / 2) - (spriteFont.MeasureString("Story: ").X / 2), 200 + spriteFont.LineSpacing * 6), Color.White);
                this.ScreenManager.SpriteBatch.DrawString(spriteFont, "Julia Fogarty", new Vector2((width / 2) - (spriteFont.MeasureString("Julia Fogarty").X / 2), 200 + spriteFont.LineSpacing * 7), Color.White);

                this.ScreenManager.SpriteBatch.DrawString(spriteFont, "Music Composer: ", new Vector2((width / 2) - (spriteFont.MeasureString("Music Composer: ").X / 2), 200 + spriteFont.LineSpacing * 9), Color.White);
                this.ScreenManager.SpriteBatch.DrawString(spriteFont, "Zack Parrish/ZackParrish.com", new Vector2((width / 2) - (spriteFont.MeasureString("Zack Parrish/ZackParrish.com").X / 2), 200 + spriteFont.LineSpacing * 10), Color.White);
                this.ScreenManager.SpriteBatch.DrawString(spriteFont, "\"Il Valzer Finale\\NothingEverLasts\\Revealing the Truth\"", new Vector2((width / 2) - (spriteFont.MeasureString("\"Il Valzer Finale\\NothingEverLasts\\Revealing the Truth\"").X / 2), 200 + spriteFont.LineSpacing * 11), Color.White);
   
                this.ScreenManager.SpriteBatch.End();

                base.Draw(gameTime);
            }
        }


        #endregion

        #region Handle Input

        public override void HandleInput(GameTime gameTime, InputState input)
        {
            if (input.CurrentKeyboardStates[(int)this.ControllingPlayer].IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape) ||
                input.CurrentKeyboardStates[(int)this.ControllingPlayer].IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Back) ||
                input.CurrentGamePadStates[(int)this.ControllingPlayer].IsButtonDown(Microsoft.Xna.Framework.Input.Buttons.B) ||
                input.CurrentGamePadStates[(int)this.ControllingPlayer].IsButtonDown(Microsoft.Xna.Framework.Input.Buttons.Back))
            {
                exiting = true;
                this.ExitScreen();
            }

            base.HandleInput(gameTime, input);
        }

        #endregion
    }
}
